﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PPE4_Diaz
{
    public partial class type_soins : Form
    {
        public type_soins()
        {
            InitializeComponent();
            chargedgv();
        }

        public void chargedgv()
        {
            //
            //Chargement de la DataGridView
            //
            dataGridView1.DataSource = controller.Vmodel.Dvtype_soins;
            dataGridView1.Columns[0].Visible = false;
            dataGridView1.Columns[3].Visible = false;
            int vwidth = dataGridView1.RowHeadersWidth;
            for (int i = 0; i < dataGridView1.Columns.Count; i++)
            {
                if (dataGridView1.Columns[i].Visible)
                    vwidth = vwidth + dataGridView1.Columns[i].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, false);
            }
            dataGridView1.Width = vwidth;
            if (dataGridView1.ScrollBars.Equals(ScrollBars.Both) | dataGridView1.ScrollBars.Equals(ScrollBars.Vertical))
            {
                dataGridView1.Width += 20;
            }
            dataGridView1.Refresh();
            //
            //Chargement de la ComboBox
            //
            ccateg.Items.Clear();
            List<KeyValuePair<int, string>> uList = new List<KeyValuePair<int, string>>();
            uList.Add(new KeyValuePair<int, string>(0, "toutes les catégories"));
            ccateg.Items.Add("toutes les catégories");
            for (int i = 0; i < controller.Vmodel.Dvcateg_soins.ToTable().Rows.Count; i++)
            {

                uList.Add(new KeyValuePair<int, string>((int)controller.Vmodel.Dvcateg_soins.ToTable().Rows[i][0], controller.Vmodel.Dvcateg_soins.ToTable().Rows[i][1].ToString()));

            }
            ccateg.DataSource = uList;
            ccateg.ValueMember = "Key";
            ccateg.DisplayMember = "Value";
            ccateg.Text = ccateg.Items[0].ToString();

            ccateg.DropDownStyle = ComboBoxStyle.DropDownList;

        }

    }
}
